<?php
namespace app\admin\controller;
class Index extends Auth{
    
    
    /**
     * 登录后进来的主商户页面
     */
    public function index(){        
        //echo '欢迎来到站点主管理页面';
        $this->assign(get_defined_vars());
        return $this->fetch();
    }
    
    /**
     * 站点管理页面
     */
    public function site($siteid = ''){        
        $loginSiteId = session('c_login_siteid');      
        if( !$loginSiteId || $siteid != $loginSiteId ){
            $userInfo = $this->getUser()->getInfo();
            $SiteList = new \logic\site\SiteList();            
            $where = [
                'msiteid'=>$userInfo['msiteid'],
                'status'=>1,
            ];
            if( $siteid ) $where['siteid'] = $siteid;
            $userSiteList = $SiteList->getSimpleList($where);
            if( count($userSiteList) > 1 ){
                $this->redirect('/index/index');
            }
            $siteInfo = $userSiteList[0];
            if( !$siteInfo ) $this->error('站点不存在');
            session('c_login_siteid',$siteInfo['siteid']);   // 紧用于指定当前操作的站点
        }        
        $this->assign(get_defined_vars());
        return $this->fetch();
    }

    public function home($name = 'ThinkPHP5'){
        echo '11';exit;
        return 'hello,' . $name;
    }
}
